package edu.hubu.book.controller;

import edu.hubu.book.domain.Book;
import edu.hubu.book.service.impl.BookServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author moonlan
 * date 2020/5/3 10:32
 */
@SuppressWarnings(value = "unused")
@Controller
public class BookController {
    @Autowired private BookServiceImpl service;

    @ResponseBody
    @RequestMapping(value = "addBook")
    public String addBook(Book book) {
        boolean addBook = service.addBook(book);
        return String.valueOf(addBook);
    }

    @ResponseBody
    @RequestMapping(value = "delBook")
    public String delBook(int bid) {
        boolean delBook = service.delBook(bid);
        return String.valueOf(delBook);
    }

    @ResponseBody
    @RequestMapping(value = "updateBook")
    public String updateBook(@RequestParam("bookId") int bid, Book book) {
        boolean delBook = service.update(bid, book);
        return String.valueOf(delBook);
    }
}
